{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "logical and\n",
      "epoch 0 sample 0 [1 2 0 0 0 0 0]\n",
      "epoch 0 sample 1 [1 2 0 1 -1 0 -1]\n",
      "epoch 0 sample 2 [0 2 -1 1 0 -1 -1]\n",
      "epoch 0 sample 3 [0 1 -2 0 1 1 1]\n",
      "epoch 1 sample 0 [1 2 -1 0 0 0 0]\n",
      "epoch 1 sample 1 [1 2 -1 0 0 0 0]\n",
      "epoch 1 sample 2 [1 2 -1 1 0 -1 -1]\n",
      "epoch 1 sample 3 [1 1 -2 0 1 1 1]\n",
      "epoch 2 sample 0 [2 2 -1 0 0 0 0]\n",
      "epoch 2 sample 1 [2 2 -1 1 -1 0 -1]\n",
      "epoch 2 sample 2 [1 2 -2 0 0 0 0]\n",
      "epoch 2 sample 3 [1 2 -2 1 0 0 0]\n",
      "epoch 3 sample 0 [1 2 -2 0 0 0 0]\n",
      "epoch 3 sample 1 [1 2 -2 0 0 0 0]\n",
      "epoch 3 sample 2 [1 2 -2 0 0 0 0]\n",
      "epoch 3 sample 3 [1 2 -2 1 0 0 0]\n",
      "epoch 4 sample 0 [1 2 -2 0 0 0 0]\n",
      "epoch 4 sample 1 [1 2 -2 0 0 0 0]\n",
      "epoch 4 sample 2 [1 2 -2 0 0 0 0]\n",
      "epoch 4 sample 3 [1 2 -2 1 0 0 0]\n",
      "epoch 5 sample 0 [1 2 -2 0 0 0 0]\n",
      "epoch 5 sample 1 [1 2 -2 0 0 0 0]\n",
      "epoch 5 sample 2 [1 2 -2 0 0 0 0]\n",
      "epoch 5 sample 3 [1 2 -2 1 0 0 0]\n",
      "epoch 6 sample 0 [1 2 -2 0 0 0 0]\n",
      "epoch 6 sample 1 [1 2 -2 0 0 0 0]\n",
      "epoch 6 sample 2 [1 2 -2 0 0 0 0]\n",
      "epoch 6 sample 3 [1 2 -2 1 0 0 0]\n",
      "epoch 7 sample 0 [1 2 -2 0 0 0 0]\n",
      "epoch 7 sample 1 [1 2 -2 0 0 0 0]\n",
      "epoch 7 sample 2 [1 2 -2 0 0 0 0]\n",
      "epoch 7 sample 3 [1 2 -2 1 0 0 0]\n",
      "epoch 8 sample 0 [1 2 -2 0 0 0 0]\n",
      "epoch 8 sample 1 [1 2 -2 0 0 0 0]\n",
      "epoch 8 sample 2 [1 2 -2 0 0 0 0]\n",
      "epoch 8 sample 3 [1 2 -2 1 0 0 0]\n",
      "epoch 9 sample 0 [1 2 -2 0 0 0 0]\n",
      "epoch 9 sample 1 [1 2 -2 0 0 0 0]\n",
      "epoch 9 sample 2 [1 2 -2 0 0 0 0]\n",
      "epoch 9 sample 3 [1 2 -2 1 0 0 0]\n",
      "logical or\n",
      "epoch 0 sample 0 [1 2 0 0 0 0 0]\n",
      "epoch 0 sample 1 [1 2 0 1 0 0 0]\n",
      "epoch 0 sample 2 [1 2 0 1 0 0 0]\n",
      "epoch 0 sample 3 [1 2 0 1 0 0 0]\n",
      "epoch 1 sample 0 [1 2 0 0 0 0 0]\n",
      "epoch 1 sample 1 [1 2 0 1 0 0 0]\n",
      "epoch 1 sample 2 [1 2 0 1 0 0 0]\n",
      "epoch 1 sample 3 [1 2 0 1 0 0 0]\n",
      "epoch 2 sample 0 [1 2 0 0 0 0 0]\n",
      "epoch 2 sample 1 [1 2 0 1 0 0 0]\n",
      "epoch 2 sample 2 [1 2 0 1 0 0 0]\n",
      "epoch 2 sample 3 [1 2 0 1 0 0 0]\n",
      "epoch 3 sample 0 [1 2 0 0 0 0 0]\n",
      "epoch 3 sample 1 [1 2 0 1 0 0 0]\n",
      "epoch 3 sample 2 [1 2 0 1 0 0 0]\n",
      "epoch 3 sample 3 [1 2 0 1 0 0 0]\n",
      "epoch 4 sample 0 [1 2 0 0 0 0 0]\n",
      "epoch 4 sample 1 [1 2 0 1 0 0 0]\n",
      "epoch 4 sample 2 [1 2 0 1 0 0 0]\n",
      "epoch 4 sample 3 [1 2 0 1 0 0 0]\n",
      "epoch 5 sample 0 [1 2 0 0 0 0 0]\n",
      "epoch 5 sample 1 [1 2 0 1 0 0 0]\n",
      "epoch 5 sample 2 [1 2 0 1 0 0 0]\n",
      "epoch 5 sample 3 [1 2 0 1 0 0 0]\n",
      "epoch 6 sample 0 [1 2 0 0 0 0 0]\n",
      "epoch 6 sample 1 [1 2 0 1 0 0 0]\n",
      "epoch 6 sample 2 [1 2 0 1 0 0 0]\n",
      "epoch 6 sample 3 [1 2 0 1 0 0 0]\n",
      "epoch 7 sample 0 [1 2 0 0 0 0 0]\n",
      "epoch 7 sample 1 [1 2 0 1 0 0 0]\n",
      "epoch 7 sample 2 [1 2 0 1 0 0 0]\n",
      "epoch 7 sample 3 [1 2 0 1 0 0 0]\n",
      "epoch 8 sample 0 [1 2 0 0 0 0 0]\n",
      "epoch 8 sample 1 [1 2 0 1 0 0 0]\n",
      "epoch 8 sample 2 [1 2 0 1 0 0 0]\n",
      "epoch 8 sample 3 [1 2 0 1 0 0 0]\n",
      "epoch 9 sample 0 [1 2 0 0 0 0 0]\n",
      "epoch 9 sample 1 [1 2 0 1 0 0 0]\n",
      "epoch 9 sample 2 [1 2 0 1 0 0 0]\n",
      "epoch 9 sample 3 [1 2 0 1 0 0 0]\n",
      "logical xor\n",
      "epoch 0 sample 0 [1 2 0 0 0 0 0]\n",
      "epoch 0 sample 1 [1 2 0 1 0 0 0]\n",
      "epoch 0 sample 2 [1 2 0 1 0 0 0]\n",
      "epoch 0 sample 3 [1 2 0 1 -1 -1 -1]\n",
      "epoch 1 sample 0 [0 1 -1 0 0 0 0]\n",
      "epoch 1 sample 1 [0 1 -1 0 1 0 1]\n",
      "epoch 1 sample 2 [1 1 0 1 0 0 0]\n",
      "epoch 1 sample 3 [1 1 0 1 -1 -1 -1]\n",
      "epoch 2 sample 0 [0 0 -1 0 0 0 0]\n",
      "epoch 2 sample 1 [0 0 -1 0 1 0 1]\n",
      "epoch 2 sample 2 [1 0 0 0 0 1 1]\n",
      "epoch 2 sample 3 [1 1 1 1 -1 -1 -1]\n",
      "epoch 3 sample 0 [0 0 0 0 0 0 0]\n",
      "epoch 3 sample 1 [0 0 0 0 1 0 1]\n",
      "epoch 3 sample 2 [1 0 1 1 0 0 0]\n",
      "epoch 3 sample 3 [1 0 1 1 -1 -1 -1]\n",
      "epoch 4 sample 0 [0 -1 0 0 0 0 0]\n",
      "epoch 4 sample 1 [0 -1 0 0 1 0 1]\n",
      "epoch 4 sample 2 [1 -1 1 0 0 1 1]\n",
      "epoch 4 sample 3 [1 0 2 1 -1 -1 -1]\n",
      "epoch 5 sample 0 [0 -1 1 1 0 0 -1]\n",
      "epoch 5 sample 1 [0 -1 0 0 1 0 1]\n",
      "epoch 5 sample 2 [1 -1 1 0 0 1 1]\n",
      "epoch 5 sample 3 [1 0 2 1 -1 -1 -1]\n",
      "epoch 6 sample 0 [0 -1 1 1 0 0 -1]\n",
      "epoch 6 sample 1 [0 -1 0 0 1 0 1]\n",
      "epoch 6 sample 2 [1 -1 1 0 0 1 1]\n",
      "epoch 6 sample 3 [1 0 2 1 -1 -1 -1]\n",
      "epoch 7 sample 0 [0 -1 1 1 0 0 -1]\n",
      "epoch 7 sample 1 [0 -1 0 0 1 0 1]\n",
      "epoch 7 sample 2 [1 -1 1 0 0 1 1]\n",
      "epoch 7 sample 3 [1 0 2 1 -1 -1 -1]\n",
      "epoch 8 sample 0 [0 -1 1 1 0 0 -1]\n",
      "epoch 8 sample 1 [0 -1 0 0 1 0 1]\n",
      "epoch 8 sample 2 [1 -1 1 0 0 1 1]\n",
      "epoch 8 sample 3 [1 0 2 1 -1 -1 -1]\n",
      "epoch 9 sample 0 [0 -1 1 1 0 0 -1]\n",
      "epoch 9 sample 1 [0 -1 0 0 1 0 1]\n",
      "epoch 9 sample 2 [1 -1 1 0 0 1 1]\n",
      "epoch 9 sample 3 [1 0 2 1 -1 -1 -1]\n"
     ]
    }
   ],
   "source": [
    "#!/usr/bin/env python3\n",
    "import numpy as np\n",
    "\n",
    "samples_and = [\n",
    "    [0, 0, 0],\n",
    "    [1, 0, 0],\n",
    "    [0, 1, 0],\n",
    "    [1, 1, 1],\n",
    "]\n",
    "\n",
    "samples_or = [\n",
    "    [0, 0, 0],\n",
    "    [1, 0, 1],\n",
    "    [0, 1, 1],\n",
    "    [1, 1, 1],\n",
    "]\n",
    "\n",
    "samples_xor = [\n",
    "    [0, 0, 0],\n",
    "    [1, 0, 1],\n",
    "    [0, 1, 1],\n",
    "    [1, 1, 0],\n",
    "]\n",
    "\n",
    "def perceptron(samples): \n",
    "    w = np.array([1, 2]) \n",
    "    b = 0 \n",
    "    a = 1 \n",
    "    for i in range(10): \n",
    "        for j in range(4): \n",
    "            x = np.array(samples[j][:2]) \n",
    "            y = 1 if np.dot(w, x) + b > 0 else 0 \n",
    "            d = np.array(samples[j][2]) \n",
    "            delta_b = a*(d-y) \n",
    "            delta_w = a*(d-y)*x \n",
    "            print('epoch {} sample {} [{} {} {} {} {} {} {}]'.format( \n",
    "                i, j, w[0], w[1], b, y, delta_w[0], delta_w[1], delta_b \n",
    "            ))\n",
    "            w = w + delta_w \n",
    "            b = b + delta_b\n",
    "            \n",
    "if __name__ == '__main__': \n",
    "    print('logical and') \n",
    "    perceptron(samples_and) \n",
    "    print('logical or') \n",
    "    perceptron(samples_or) \n",
    "    print('logical xor') \n",
    "    perceptron(samples_xor)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "逻辑与：从上述log可以看出，最终在\"epoch 2 sample 2 [1 2 -2 0 0 0 0]\"这条记录后，参数就停止更新，最终得到的参数为：w1 = 1, w2 = 2, b = -2;\n",
    "\n",
    "逻辑或： 从上述log可以看出，最终在“epoch 0 sample 0 [1 2 0 0 0 0 0]”这条记录后，参数就停止更新，巧合，刚好初始化参数满足条件。最终得到的参数为：w1 = 1, w2 = 2, b = 0;\n",
    "\n",
    "逻辑异或：从上述log可以看出，参数一直在不停地更新，并没有像逻辑与和逻辑或的问题一样，收敛到某个参数上。事实上，并不存在满足条件的参数。\n",
    "异或，在坐标上的画法如下,不存在一条直线可以将两类正确分隔开。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEWCAYAAABrDZDcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAUsklEQVR4nO3df5Bd5X3f8fcHCCEKGP+QMrWRQMQR02iYTHAXSpJOjYrbAdKgTEsZVFxMSq0JLs4kdpPQEmQqameC07GbhmDLP4LjysYbpnVUVx7aiZdxkwDVMjiEH2VQMD9U7LDGNoYoGMv+9o9zha9Wd6UVumdXq+f9mtm59zznued8H+1qP3vOufc8qSokSe06ZrELkCQtLoNAkhpnEEhS4wwCSWqcQSBJjTMIJKlxBoE0T0muTPInQ8svJPnRxaxJGofjFrsAaamqqhMXuwZpHDwikIAkR8wfRUdSLWqDQaAlK8kbk3w9yZsGy29I8rUk5w0tbxv02Znk7UOvvSHJ7Un+S5JvAVeO2P7rBq//VpL/A7xx1vpK8mOD5z+b5L5B36eS3DCr7xVJnkjybJLrkzye5C1z1ZLknCR3Jflmkq8k+d0kx8/a9zuSPJrk+SQ3Dv497hrUMDncXzoQg0BLVlX9JfDrwNYky4DfB26tqjsHXT4N7ALeAFwCvC/J+UObWA/cDrwa2DpiFzcDLwKvB/7l4Gsufw1cMdjWzwJXJ/l5gCRrgd8DLh9s62TglFmvn13Ld4FfAZYDPwWcD7xj1msuAP4OcC7wa8CWwT5WAWcCGw5Qr/Qyg0BLWlV9BHgUuIful+x1AElWAX8P+PWqerGqvgR8FPgXQy+/q6o+W1Xfq6q/Gd5ukmOBfwpsqqq/rqoHgE8coI47q+ovBtu6ny6E3jxYfQnw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Bx1zkrOAVVX1uYUsrEfz+T6fAZyR5E+T3J3kggWrrh/zGfMNwFuT7KKb/+SdC1PaojnU/+8H1evENItk1F/2s98jO58+S8m8x5PkrcAE8OZeK+rfAcec5BjgA8CVC1XQApjP9/k4utND59Ed9f3vJGdW1Td7rq0v8xnzBuDWqvqPSX4K+ORgzN/rv7xFMfbfX0fjEcEuYNXQ8kr2P1R8uU+S4+gOJw90KHakm8+YSfIW4Drg4qr69gLV1peDjfkk4EzgziSP051L3bbELxjP92f7j6rqO1X1ZeARumBYquYz5quASYCqugs4ge7mbEeref1/PxRHYxDsANYkOT3J8XQXg7fN6rMNeNvg+SXAF2pwFWaJOuiYB6dJPkwXAkv9vDEcZMxV9VxVLa+q1VW1mu66yMVVtZQnvJ7Pz/Zn6d4YQJLldKeKDjgP+BFuPmN+EjgfIMmP0wXBzIJWubC2AVcM3j10LvBcVX3lcDZ41J0aqqo9Sa4B7qB7x8HHq+rBJJuB6araBnyM7vBxJ92RwGWLV/Hhm+eY3w+cCPzh4Lr4k1V18aIVfZjmOeajyjzHfAfwj5I8BHwX+NWqenbxqj488xzzu4GPJPkVulMkVy7lP+ySfJru1N7ywXWP9wA/AFBVH6K7DnIRsBPYDfzCYe9zCf97SZLG4Gg8NSRJOgQGgSQ1ziCQpMYZBJLUOINAkhpnEEhS4wwCSWqcQSAdpiRnD+4Lf0KSHx7MA3DmYtclzZcfKJPGIMl/oLu1wQ8Bu6rqNxe5JGneDAJpDAb3wdlBN+/BT1fVdxe5JGnePDUkjcdr6e7ldBLdkYG0ZHhEII1Bkm10s2edDry+qq5Z5JKkeTvq7j4qLbQkVwB7qupTSY4F/izJP6iqLyx2bdJ8eEQgSY3zGoEkNc4gkKTGGQSS1DiDQJIaZxBIUuMMAklqnEEgSY37/yGg2sQMfE3GAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "plt.title('xor diagram')\n",
    "plt.xlabel(\"x\")\n",
    "plt.ylabel(\"y\")\n",
    "plt.plot([0,1],[0,1],'ro')\n",
    "plt.plot([1,0],[0,1],'bx')\n",
    "\n",
    "\n",
    "plt.plot([0.5,0.5],[0,1],'y')\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:tf1.14]",
   "language": "python",
   "name": "conda-env-tf1.14-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
